#获取假天花板的高度值
from xml.etree import ElementTree as ET
tree=ET.parse(r"F:\桌面\user_config.xml")
root=tree.getroot()
wall_height=root.find('OtherSettings').find('GlobalFalseCeiling').find('height').text

#修改假天花板的高度值
wall_height=str(float(wall_height)-100)
#寻找Pipe和Duct的Z坐标
tree=ET.parse(r"F:\桌面\Sample View 5.xml")
root=tree.getroot()
Entitys =root.find('Entitys')
for Entity in Entitys:
    # print(Entity.attrib['type'])
    Type = Entity.attrib['type']
    if (Type == 'Pipe' or Type == 'Duct'):
        LocationEnt = Entity.find('LocationEnt')
        #修改管道的Z坐标值
        StartPoint = LocationEnt.attrib['StartPoint']
        StartPoint_List=StartPoint.split(',')
        StartPoint_List[2]=wall_height
        LocationEnt.attrib['StartPoint']=StartPoint_List[0]+','+StartPoint_List[1]+','+StartPoint_List[2]
        # print('起点坐标:',end='')
        # print(StartPoint,end='   ')

        EndPoint = LocationEnt.attrib['EndPoint']
        EndPoint_List=EndPoint.split(',')
        EndPoint_List[2]=wall_height
        LocationEnt.attrib['EndPoint'] = EndPoint_List[0]+','+EndPoint_List[1]+','+EndPoint_List[2]
        # print('终点坐标:',end='')
        # print(EndPoint)
#生成修改后的文件
tree=ET.ElementTree(root)
tree.write("F:\桌面\B.xml",encoding='utf-8')